package com.cc.factory;

public class Test01 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        //1.以前：
//        RedPig redPig = new RedPig(12, "旺财");
//        BlackPig blackPig = new BlackPig(11, "来福");
        //2.自己写工厂  
//        BlackPig blackPig =  (BlackPig) PigFacotry.getPig("black");
//        RedPig redPig =  (RedPig) PigFacotry.getPig("red");
//        YellowPig yellowPig =  (YellowPig) PigFacotry.getPig("yellow");
//        BluePig bluePig =(BluePig) PigFacotry.getPig("blue");
//        System.out.println(bluePig);
        //3.自己写工厂  --反射
        BlackPig blackPig =  (BlackPig) ObjectFacotry.getPig(BlackPig.class);
        System.out.println(blackPig);
        
        RedPig redPig =  (RedPig) ObjectFacotry.getPig(RedPig.class);
        System.out.println(redPig);
        
        PinkPig pinkPig =  (PinkPig) ObjectFacotry.getPig(PinkPig.class);
        System.out.println(pinkPig);
        
    }
}
